﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ObserverAndMediator
{
    /// <summary>
    /// 貴族
    /// </summary>
    public class Nobleman : EventCustomer
    {
        /// <summary>
        /// 定義貴族能夠處理的事件的級別
        /// </summary>
        public Nobleman() : base(EventCustomType.EDIT)
        {
            base.addCustomType(EventCustomType.CLONE);
        }

        public override void exec(ProductEvent events)
        {
            //事件的源頭
            Product p = events.Source;
            //事件類型
            ProductEventType type = events.EventType;

            if ((int)type == (int)EventCustomType.CLONE)
            {
                Console.WriteLine("貴族處理事件：" + p.Name + " 克隆，事件類型 = " + type);
            }
            else
            {
                Console.WriteLine("貴族處理事件：" + p.Name + " 修改，事件類型 = " + type);
            }
           
        }
    }
}
